<%#
kind: user_data
name: AutoYaST default user data
model: ProvisioningTemplate
oses:
- OpenSUSE
- SLES
description: |
  This template is used during image based provisioning, when the image is configured to use user-data.
  The output is a shell script that cloud-init runs to configures the VM
  booted from the image. The image must have cloud-init installed in order for this to work.
  This script can be used with OpenSUSE and SLES images.
-%>
<%
  # safemode renderer does not support unary negation
  puppet_enabled = !host_param_true?('skip-puppet-setup') && (host_puppet_server.present? || host_param_true?('force-puppet'))
  salt_enabled = host_param('salt_master') ? true : false
-%>
#!/bin/bash

<%# Cloud instances frequently have incorrect hosts data %>
<%= snippet 'fix_hosts' %>

<% if @host.provision_method == 'image' && root_pass.present? -%>
# Install the root password
echo 'root:<%= root_pass -%>' | /usr/sbin/chpasswd -e
<% end -%>

<%= snippet('remote_execution_ssh_keys') %>

<%= snippet "blacklist_kernel_modules" %>

<% if puppet_enabled %>
<% if host_param_true?('enable-official-puppet8-repo') || host_param_true?('enable-official-puppet7-repo') || host_param_true?('enable-puppetlabs-puppet6-repo') || host_param_true?('enable-puppetlabs-puppet5-repo') -%>
<%= snippet 'puppetlabs_repo' %>
<% end -%>
<%= snippet 'puppet_setup' %>
<% end -%>

<% if salt_enabled %>
<%= snippet 'saltstack_setup' %>
<% end -%>

# UserData still needs to mark the build as finished
<%= snippet 'built' %>
